﻿from sys import argv
from SenderLBCrawlerAgent import SenderLBCrawlerAgent
from RandomLBCrawlerAgent import RandomLBCrawlerAgent
from CentralLBCrawlerAgent import CentralLBCrawlerAgent
from LBCrawlerAgent import LBCrawlerAgent


if __name__ == '__main__':
  if len(argv) > 3:
    agents = {'1': SenderLBCrawlerAgent,
              '2': RandomLBCrawlerAgent,
              '3': CentralLBCrawlerAgent,
              '4': LBCrawlerAgent}
    cons_hash = True
    num = 1
    fname = None
    if len(argv) > 4:
      cons_hash = bool(int(argv[4]))
    if len(argv) > 5:
      num = int(argv[5])
    if len(argv) > 6:
      fname = argv[6]
    a = agents[argv[3]](argv[1] + '@' + argv[2], 'secret', num=num, fname=fname)
    a.start()
  else:
    print 'Usage: %s agent_name server_ip LB_type [number_of_threads=1 seed_urls_file=None]' % (argv[0],)
    print 'LB_type:'
    print '\t1 - SenderLB'
    print '\t2 - RandomLB'
    print '\t3 - CentralizedLB'
    print '\t4 - ConsistentHashingOnly'
